package handler

import (
	"api/basic/global"
	__ "api/basic/proto"
	"api/internal/params"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Register(c *gin.Context) {
	var req *params.Register
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	register, err := global.UserClient.Register(c, &__.RegisterReq{
		Mobile:   req.Mobile,
		Code:     req.Code,
		Password: req.Password,
	})
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "注册成功",
		"data": register,
	})
}
